package main

import (
	"fmt"
	"sync"
)

func main() {
	chLetter := make(chan (bool))
	chNum := make(chan (bool))

	fmt.Printf("letterLen=%v\n", len(chLetter))
	fmt.Printf("chNum=%v\n", len(chNum))
	wgPrint := sync.WaitGroup{}

	// 字母处理 协程
	go func() {
		currLetter := 'A'
		fmt.Printf("goFunc letter start\n")

		for {
			select {
			case <-chLetter:
				// fmt.Printf("chan pop|currLetter=%c\n", currLetter)
				fmt.Print(string(currLetter))
				currLetter++
			}

			if currLetter > 'Z' {
				wgPrint.Done()
				fmt.Print("\n")
			} else {
				chNum <- true
			}
		}

	}()
	wgPrint.Add(1)

	// 数字处理 协程
	go func() {
		fmt.Printf("goFunc num start")
		currNum := 0
		for {
			select {
			case <-chNum:
				// fmt.Printf("chan pop|currNum=%v\n", currNum)
				fmt.Print(currNum)
				currNum++
			}

			chLetter <- true
		}
	}()

	fmt.Printf("wgPrint wait start\n")

	chLetter <- true

	wgPrint.Wait()

}
